package cc.core.pullrefresh.extra;

import cc.core.pullrefresh.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
 * cc.core.pullrefresh.extra.FooterLayout
 *
 * @author YuanChao <br/>
 *         create at 2015年6月22日 下午1:43:59
 */
public class FooterLayout extends BaseFooterLayout {
    private static final String TAG = "FooterLayout";
    protected TextView textView;
    protected ProgressBar progressBar;
    protected boolean isError;

    public FooterLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context, attrs);
    }

    @Override
    public void initView(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.layout_footer, this);
        textView = (TextView) findViewById(R.id.tv_pr_lv_footer);
        progressBar = (ProgressBar) findViewById(R.id.pg_pr_lv_footer);
    }

    @Override
    public void updateTitle() {
    }

    public TextView getFooterText() {
        if (textView == null)
            textView = (TextView) findViewById(R.id.tv_pr_lv_footer);
        return textView;
    }

    public ProgressBar getProgressBar() {
        if (progressBar == null)
            progressBar = (ProgressBar) findViewById(R.id.pg_pr_lv_footer);
        return progressBar;
    }

    public void setError(boolean isError) {
        this.isError = isError;
        if (isError) {
            getFooterText().setVisibility(VISIBLE);
            getProgressBar().setVisibility(GONE);
        } else {
            getFooterText().setVisibility(GONE);
            getProgressBar().setVisibility(VISIBLE);
        }
    }

    @Override
    public void setRefreshing() {

    }

    @Override
    public void onHeaderRefreshing(boolean isRefreshing) {

    }

    public boolean isError() {
        return isError;
    }

    @Override
    public void setAnimValue(float value) {
    }

    @Override
    public void setPullValue(int value) {
    }

}
